package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.ArchiveBoxInoutdetail;
import com.hiultra.archive.service.IArchiveBoxInoutdetailService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 档案盒进出记录详情Controller
 *
 * @author 派大星
 * @date 2024-07-23
 */
@RestController
@RequestMapping("/archive/ArchiveBoxInoutdetail")
public class ArchiveBoxInoutdetailController extends BaseController
{
    @Autowired
    private IArchiveBoxInoutdetailService archiveBoxInoutdetailService;

    /**
     * 查询档案盒进出记录详情列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxInoutdetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchiveBoxInoutdetail archiveBoxInoutdetail)
    {
        startPage();
        List<ArchiveBoxInoutdetail> list = archiveBoxInoutdetailService.selectArchiveBoxInoutdetailList(archiveBoxInoutdetail);
        return getDataTable(list);
    }

    /**
     * 导出档案盒进出记录详情列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxInoutdetail:export')")
    @Log(title = "档案盒进出记录详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveBoxInoutdetail archiveBoxInoutdetail)
    {
        List<ArchiveBoxInoutdetail> list = archiveBoxInoutdetailService.selectArchiveBoxInoutdetailList(archiveBoxInoutdetail);
        ExcelUtil<ArchiveBoxInoutdetail> util = new ExcelUtil<ArchiveBoxInoutdetail>(ArchiveBoxInoutdetail.class);
        util.exportExcel(response, list, "档案盒进出记录详情数据");
    }

    /**
     * 获取档案盒进出记录详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxInoutdetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(archiveBoxInoutdetailService.selectArchiveBoxInoutdetailById(id));
    }

    /**
     * 新增档案盒进出记录详情
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxInoutdetail:add')")
    @Log(title = "档案盒进出记录详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveBoxInoutdetail archiveBoxInoutdetail)
    {
        return toAjax(archiveBoxInoutdetailService.insertArchiveBoxInoutdetail(archiveBoxInoutdetail));
    }

    /**
     * 修改档案盒进出记录详情
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxInoutdetail:edit')")
    @Log(title = "档案盒进出记录详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveBoxInoutdetail archiveBoxInoutdetail)
    {
        return toAjax(archiveBoxInoutdetailService.updateArchiveBoxInoutdetail(archiveBoxInoutdetail));
    }

    /**
     * 删除档案盒进出记录详情
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxInoutdetail:remove')")
    @Log(title = "档案盒进出记录详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(archiveBoxInoutdetailService.deleteArchiveBoxInoutdetailByIds(ids));
    }
    /**
     * 获取档案盒进出记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxInoutdetail:query')")
    @GetMapping(value = "/selectArchiveBoxByRecordId/{recordId}")
    public AjaxResult selectArchiveBoxByRecordId(@PathVariable("recordId") String recordId)
    {
        List<ArchiveBoxInoutdetail> data = archiveBoxInoutdetailService.selectArchiveBoxByRecordId(recordId);
        return AjaxResult.success(data);
    }
}
